package com.singfan.manage.vm.partial;

import com.singfan.core.dao.database.model.constant.BusinessStatusType;

/**
 * Author: hansonghe
 * Date: 2015-10-20 15:27
 * Desc:
 */
public class ShopListItem {
    private int num;
    private long shopId;
    private String masterName;
    private String slaveName;
    private int honor;
    private int status;

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public long getShopId() {
        return shopId;
    }

    public void setShopId(long shopId) {
        this.shopId = shopId;
    }

    public String getMasterName() {
        return masterName;
    }

    public void setMasterName(String masterName) {
        this.masterName = masterName;
    }

    public String getSlaveName() {
        return slaveName;
    }

    public void setSlaveName(String slaveName) {
        this.slaveName = slaveName;
    }

    public int getHonor() {
        return honor;
    }

    public void setHonor(int honor) {
        this.honor = honor;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    @Override
    public String toString() {
        return String.format("<tr><td>%1$d</td><td>%2$s</td><td>%3$s</td><td>%4$d</td><td>%5$s</td><td>%6$s</td></tr>", num, masterName, slaveName, honor, BusinessStatusType.getBusinessStatusTypeTest(status), getOpText(shopId, status));
    }

    private String getOpText(long shopId, int status){
        String opTemp1 = "<input type=\"button\" value=\"查看\" onclick='shopView(\"%1$d\")' /> | <input type=\"button\" value=\"修改\" onclick='shopUpdate(\"%1$d\")'/> | <input id=\"btnOp1-%1$d\" type=\"button\" value=\"禁用\" style=\"display: %2$s\" onclick='shopStatus(\"%1$d\",true)' /><input id=\"btnOp2-%1$d\" type=\"button\" value=\"启用\" style=\"display: %3$s\" onclick='shopStatus(\"%1$d\",false)' /> | <input type=\"button\" value=\"重置密码\" onclick='shopReset(\"%1$d\")'/>";
        String display1;
        String display2;
        if (status == BusinessStatusType.FORBIDDEN){
            display1 = "none";
            display2 = "inherit";
        }
        else {
            display1 = "inherit";
            display2 = "none";
        }

        return String.format(opTemp1, shopId, display1, display2);
    }
}
